package com.todo.strategy.online.application.frontend.controller;

import com.todo.common.common.entity.response.BizResponse;
import com.todo.strategy.online.application.frontend.service.PlanContentAggService;
import com.todo.strategy.online.iface.PlanContentFrontendIface;
import com.todo.strategy.online.iface.request.InsertPlanContentParam;
import com.todo.strategy.online.iface.request.QueryPlanContentByIdParam;
import com.todo.strategy.online.iface.request.RemovePlanContentParam;
import com.todo.strategy.online.iface.request.UpdatePlanContentParam;
import com.todo.strategy.online.iface.response.PlanContentInfoVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author azhebuxing
 * @date 2024/5/21 14:23
 * @description
 */
@Slf4j
@RestController
@RequestMapping("/strategy")
@Tag(name = "计划清单内容前台接口", description = "计划清单内容前台接口")
public class PlanContentFrontendController implements PlanContentFrontendIface {

    @Resource
    private PlanContentAggService planContentAggService;


    @Override
    @Operation(summary = "新增计划清单关联内容")
    @PostMapping("/insertPlanContent")
    public BizResponse<Boolean> insertPlanContent(InsertPlanContentParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return planContentAggService.insertPlanContent(param);
    }

    @Override
    @Operation(summary = "更新计划清单关联内容")
    @PostMapping("/updatePlanContent")
    public BizResponse<Boolean> updatePlanContent(UpdatePlanContentParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return planContentAggService.updatePlanContent(param);
    }

    @Override
    @Operation(summary = "删除计划清单关联内容")
    @PostMapping("/removePlanContent")
    public BizResponse<Boolean> removePlanContent(RemovePlanContentParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return planContentAggService.removePlanContent(param);
    }

    @Override
    @Operation(summary = "根据计划清单Id查询关联内容列表")
    @PostMapping("/queryPlanContentById")
    public BizResponse<PlanContentInfoVO> queryPlanContentById(QueryPlanContentByIdParam param) {
        if (param == null) {
            return BizResponse.success("查询异常，请刷新后重新操作");
        }
        if (!param.baseCheck()) {
            return BizResponse.success("查询失败，请刷新后重新操作");
        }
        return planContentAggService.queryPlanContentById(param);
    }
}
